<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" %>
<%@page import="util.Info" %>
<%@page import="dao.CommDAO" %>
<%@page import="util.PageManager" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
    <base href="<%=basePath%>">
    <title>私人牙科诊所病例管理系统</title>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
</head>
<body>
<center>
    <jsp:include page="top.jsp"></jsp:include>
    <%
        HashMap user = (HashMap) session.getAttribute("user");
        CommDAO dao = new CommDAO();
    %>

    <script type="text/javascript" src="/srykzsblmis/commfiles/js/calendar/WdatePicker.js"></script>
    <div style="margin-top:10px;text-align:center;">
        <table width=800 border="0" cellpadding="0" cellspacing="0">
            <tr height=320 bgcolor="#1FA9FE" style="color:white;font-weight:bold;">
                    <%if (user == null) { %>
                <td align="center" width=260 bgcolor="#ECECED" valign="top" style="">
                    <jsp:include page="left.jsp"></jsp:include>
                </td>
                    <%} else { %>
                <td align="center" width=110 bgcolor="#ECECED" valign="top" style="">
                    <jsp:include page="menu.jsp"></jsp:include>
                </td>
                    <%} %>
                <td align="left" bgcolor="white"
                    style="padding-left:20px;padding-top:15px;color:Black;font-weight:normal;font-size:12px"
                    valign="top">
                    <form action="dutylist.jsp?f=f" method="post">
                        <%
                            String sql = "SELECT sy.*, s.*, dept.deptname FROM schedule s " + "LEFT JOIN sysuser sy ON s.doctor_id = sy.id AND sy.utype = '医生' " + "LEFT JOIN dept ON dept.id = sy.dept " + "WHERE 1 = 1";
                            String url = "/srykzsblmis/dutylist.jsp?1=1";
                            String key = request.getParameter("key") == null ? "" : request.getParameter("key");
                            String key1 = request.getParameter("key1") == null ? "" : request.getParameter("key1");
                            String f = request.getParameter("f");
                            if (f == null) {
                                key = Info.getUTFStr(key);
                            }
                            if (!key.equals("")) {
                                sql += " AND (sy.uname LIKE '%" + key + "%' OR sy.tname LIKE '%" + key + "%')";
                                url += "&key=" + key;
                            }
                            if (!key1.equals("")) {
                                sql += " AND (s.status = '" + key1 + "')";
                                url += "&key1=" + key1;
                            }
                            sql += " ORDER BY s.shift_date asc, s.shift_date desc";
                            PageManager pageManager = PageManager.getPage(url, 10, request);
                            pageManager.doList(sql);
                            PageManager bean = (PageManager) request.getAttribute("page");
                            ArrayList<HashMap> nlist = (ArrayList) bean.getCollection();
                        %>
                        <TABLE border="1" bordercolor="#000000" cellspacing="0" cellpadding="2"
                               style="border-collapse:collapse;font-size:12px" width="100%" align="center">
                            <th bgcolor="#ffffff" colspan="14">
                                按姓名查询：<input type="text" id="key" name="key" value="<%= key %>"/>&nbsp;&nbsp;&nbsp;
                                按状态查询：<select id="key1" name="key1">
                                <option value="">全部</option>
                                <option value="预约" <%= key1.equals("预约") ? "selected" : "" %>>预约</option>
                                <option value="停诊" <%= key1.equals("停诊") ? "selected" : "" %>>停诊</option>
                            </select>
                                <input type="submit" value="查询"/>
                            </th>
                            <TR bgcolor="#ffffff" align="center">
                                <TD>科室</TD>
                                <TD>姓名</TD>
                                <TD>头像</TD>
                                <TD>性别</TD>
                                <TD>电话</TD>
                                <TD>用户类型</TD>
                                <TD>值班日期</TD>
                                <TD>值班时间</TD>
                                <TD>状态</TD>
                            </TR>
                            <%
                                for (HashMap mstu : nlist) {
                            %>
                            <tr bgcolor="#ffffff" align="center">
                                <td><%= mstu.get("deptname") %>
                                </td>
                                <td><%= mstu.get("tname") %>
                                </td>
                                <td>
                                    <%
                                        String img = mstu.get("avatar") == null ? "" : mstu.get("avatar").toString();
                                        if (img.equals("")) {
                                    %>
                                    <img src="uploads/3.png" width="50" height="50"/>
                                    <%
                                    } else { %>
                                    <img src="<%=img %>" width="50" height="50"/>
                                    <%
                                        }%>
                                </td>
                                <td><%= mstu.get("sex") %>
                                </td>
                                <td><%= mstu.get("tel") %>
                                </td>
                                <td><%= mstu.get("utype") %>
                                </td>
                                <td><%= mstu.get("shift_date") %>
                                </td>
                                <td><%= mstu.get("shift_time") %>
                                </td>
                                <td>
                                    <%= "预约".equals(mstu.get("status")) ? "<font color='green'>可预约</font>" : "<font color='red'>已停诊</font>" %>
                                </td>
                            </tr>
                            <%
                                }
                            %>
                            <tr>
                                <td colspan="14" align="center" bgcolor="#FFFFFF">${page.info} </td>
                            </tr>
                        </TABLE>

                    </form>
        </table>
        </td>
        </tr>
        </table>
        <div style="margin-top:10px;height:1px;background-color:#1FA9FE;text-align:center;width:800px;">
        </div>

    </div>
    <jsp:include page="foot.jsp"></jsp:include>
</center>
</body>
</html>
<script type="text/javascript">
    <%
    String suc = (String) request.getAttribute("suc");
    String no = (String) request.getAttribute("no");
    if (no != null) {
    %>
    alert("用户名或密码不正确");
    <% }
    if (suc != null) {
    %>
    location.replace("/srykzsblmis/index.jsp");
    <% } %>
</script>
